//
//  ViewController.m
//  blockDemo
//
//  Created by wanglei on 17/2/21.
//  Copyright © 2017年 wanglei. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property(nonatomic,strong)NSString *name;
@property(nonatomic,copy) void(^testBlock)();
@property(nonatomic,strong)NSString *str1;
@property(nonatomic,assign)int k;
@end

NSString *str = @"静态变量";
NSString *str2 = @"静态变量";
int j = 10;
@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //        int i = 10;
    //        void(^block)() = ^{
    //            NSLog(@"block内部的i值为 : %d",i);
    //        };
    //        i ++;
    //        NSLog(@"i = %d",i);
    //     block();
    
    
    
//    static int i = 10;
//    self.k = 10;
//    
//    void(^block)() = ^{
//        i ++;
//        _k ++;
//        j ++;
//
//        NSLog(@"block内部的i = %d,j = %d, k = %d",i,j,_k);
//    };
//    i ++;
//    _k ++;
//    j ++;
//    NSLog(@"i = %d,j = %d, k = %d",i,j,_k);
//    block();
    
  
//    NSMutableString *str = [[NSMutableString alloc]initWithString:@"abc"];
//    void(^block)() = ^{
//      //  str = [[NSMutableString alloc]initWithString:@"def"];
//        [str appendString:@"def"];
//        NSLog(@"%@",str);
//    };
//    block();
    
   
    static NSString *str3 = @"静态变量";
    self.str1 = @"属性";
    void(^block)() = ^{
        self.str1 = @"属性+";
        str3 = @"静态变量+";
        str2 = @"全局变量+";
        NSLog(@"self.str1 = %@,str2 = %@,str3 = %@",self.str1,str2,str3);
    };
    block();

    
}


- (void)blockFenlei{
    
    //    int i = 10;
    //    NSLog(@"%@",^{
    //        NSLog(@"%d",i);
    //    });
    
    
    //   self.name = @"lily";
    //    NSLog(@"%@",^{
    //        NSLog(@"%@",self.name);
    //    });
    
    
    //    int i = 10;
    //    void(^block)() = ^{
    //        NSLog(@"%d",i);
    //    };
    //    NSLog(@"%@",block);
    
    
    //    int i = 10;
    //    self.testBlock = ^{
    //        NSLog(@"%d",i);
    //    };
    //    NSLog(@"%@",self.testBlock);
    
    
    //    self.testBlock = ^{
    //    };
    //    NSLog(@"%@",self.testBlock);
    
    
    static NSString *str1 = @"静态变量";
    
    void(^quanjvBlock)() = ^{
        
        NSLog(@"%@,%@",str,str1);
    };
    
    NSLog(@"%@",quanjvBlock);
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
